﻿<!DOCTYPE html>
<html>
    <title>添加</title>
</head>
<link rel="stylesheet" href="/static/layui/css/layui.css" />
<body>
<form class="layui-form"  action="" lay-filter="add">
    <input type="hidden" name="id">
    <div class="layui-inline">
        <label class="layui-form-label">标题：</label>
        <div class="layui-input-inline">
            <input type="text" name="title" id="title" lay-verify="required" placeholder="请输入id" autocomplete="off" class="layui-input">
        </div>
    </div>

    <div class="layui-inline">
        <label class="layui-form-label">内容：</label>
        <div class="layui-input-inline">
            <input type="text" name="contents" id="contents" lay-verify="required" placeholder="请输入内容" autocomplete="off" class="layui-input">
        </div>
    </div>
<!--    <div class="layui-inline">-->
<!--        <label class="layui-form-label">创建时间：</label>-->
<!--        <div class="layui-input-inline">-->
<!--            <input type="text" name="create_datetime" id="create_datetime" lay-verify="required" placeholder="创建时间" autocomplete="off" class="layui-input">-->
<!--        </div>-->
<!--    </div>-->

    <div class="layui-form-item">
        <div class="layui-input-block">
            <button class="layui-btn" lay-submit lay-filter="formDemo">立即提交</button>
        </div>
    </div>
</form>
</body>
<script src="/static/js/jquery-3.3.1.js"></script>
<script src="/static/layui/layui.js"></script>
<script>
    //Demo
    layui.use(['form','laydate'], function(){
        var form = layui.form
            ,laydate = layui.laydate;
        // laydate.render({
        //     elem: '#create_datetime'
        // });

        //监听提交
        form.on('submit(formDemo)', function(data){
            var data1 = form.val("add");
            $.ajax({
                url:'/announ/insert',
                type:"post",
                dataType:"json",
                data:data1,
                success:function (da) {
                    if (da.code == 200) {
                        layer.alert("添加成功！", function () {
                            // window.parent.location.reload();//刷新父页面
                            // parent.layer.close(layer.index);//关闭弹出层
                            parent.layer.closeAll();
                        });
                    } else {
                        layer.msg("添加失败！");
                    }
                }
            });
            return false;
        });
    });
</script>
</html>